<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — </label><br/>
      <label size="large" label-width="280px">* * * 供水爆管影响范围模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — </label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="300px">
      <el-form-item label="容器内介质压力" prop="p">
        <el-input-number v-model="formData.p" placeholder="请输入容器内介质压力" show-word-limit clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="介质密度(kg/L)" prop="density">
        <el-input-number v-model="formData.density" placeholder="请输入介质密度(kg/L)" show-word-limit clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="裂口面积(m^2)" prop="a">
        <el-input-number v-model="formData.a" placeholder="请输入裂口面积(m^2)" show-word-limit clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="裂口之上液位高度(m)" prop="h">
        <el-input-number v-model="formData.h" placeholder="请输入裂口之上液位高度(m)" show-word-limit clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="泄露时间(s)" prop="time">
        <el-input-number v-model="formData.time" placeholder="请输入泄露时间(s)" show-word-limit clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>液体泄露速度（单位：kg／s）:{{Qo}};泄露半径（单位：m）:{{r}}</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handlerRLGD21} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,
        formData: {
          p: '',
          density: '',
          a: '',
          h: '',
          time: '',
        },
        rules: {
          p: [{
            required: true,
            message: '请输入容器内介质压力',
            trigger: 'blur'
          }],
          density: [{
            required: true,
            message: '请输入介质密度(kg/L)',
            trigger: 'blur'
          }],
          a: [{
            required: true,
            message: '请输入裂口面积(m^2)',
            trigger: 'blur'
          }],
          h: [{
            required: true,
            message: '请输入裂口之上液位高度(m)',
            trigger: 'blur'
          }],
          time: [{
            required: true,
            message: '请输入泄露时间(s)',
            trigger: 'blur'
          }],
        },
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handlerRLGD21(this.formData).then(response => {
          console.log(response)
          this.Qo = response.Qo;
          this.r = response.r;
          this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
